Skip to content

Make exported case numbers clickable and visibly styled hyperlinks using ExcelJS in XLSX export#172

Closed
Copilot wants to merge 9 commits intomainfrom
copilot/update-export-feature-hyperlinks
Closed

Make exported case numbers clickable and visibly styled hyperlinks using ExcelJS in XLSX export#172
Copilot wants to merge 9 commits intomainfrom
copilot/update-export-feature-hyperlinks

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

Case export already produced .xlsx, but hyperlink styling was not reliable with the SheetJS community writer. This update reimplements export workbook generation with ExcelJS to preserve clickable hyperlinks and visible hyperlink formatting in Excel.

  • Library migration

    • Replaced SheetJS workbook generation in the export handler with ExcelJS.
    • Added exceljs as a serverless dependency and updated lockfile.
  • Export behavior preserved

    • Keeps exported Case Number text unchanged.
    • Uses the same case filtering and row generation logic.
    • Keeps the same worksheet name (Cases), filename format, response headers, and base64 download behavior.
    • Does not add a separate Case URL column.
  • Hyperlink implementation in ExcelJS

    • Applies hyperlinks on Case Number cells using ExcelJS native hyperlink value objects:
      • cell.value = { text: caseNumber, hyperlink: caseUrl }
    • Applies visible hyperlink styling on linked cells:
      • blue font (FF0563C1)
      • underline (true)
  • Column sizing preserved

    • Reimplemented auto-width behavior with the same min/max bounds used previously.
  • Focused export test coverage updated

    • Rewrote export handler tests to mock ExcelJS workbook/worksheet APIs.
    • Validates row output, hyperlink assignment, styling assignment, offense-level behavior, and filename format.
    • Updates quoted-value hyperlink test expectations to the ExcelJS value-object model.
const caseNumberCell = ws.getRow(idx + 2).getCell(caseNumberColumn);
caseNumberCell.value = { text: caseNumber, hyperlink: caseUrl };
caseNumberCell.font = {
  ...(caseNumberCell.font || {}),
  color: { argb: 'FF0563C1' },
  underline: true,
};

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 15, 2026 13:58
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copilot AI changed the title [WIP] Update export feature to maintain clickable hyperlinks Make exported case links clickable in XLSX case export Feb 15, 2026
Copilot AI requested a review from jayhill February 15, 2026 14:01
@jayhill
Copy link
Contributor

jayhill commented Feb 15, 2026

@copilot Instead of adding a column with the portal URL for the case, make the case number a clickable hyperlink. Text should remain the case number, and if there is a portal case number (case was found in the portal), then associate it with the portal URL and make it a hyperlink.

Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot Instead of adding a column with the portal URL for the case, make the case number a clickable hyperlink. Text should remain the case number, and if there is a portal case number (case was fou...

Updated in commit c610aac. The export now keeps the displayed text as the case number and applies the hyperlink directly to the Case Number cell when a portal caseId exists. I removed the added Case URL column and adjusted the export tests accordingly.

Copilot AI changed the title Make exported case links clickable in XLSX case export Make exported case numbers clickable hyperlinks in XLSX case export Feb 15, 2026
@jayhill
Copy link
Contributor

jayhill commented Feb 15, 2026

@copilot It looks like the feature works, but there is no visual identifier in the spreadsheet to indicate that there are hyperlinks. Does the styling need to be applied, explicitly or is there a default that can be used? I'd expect blue, underlined text for hyperlinks and the standard text style, if not.

Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot It looks like the feature works, but there is no visual identifier in the spreadsheet to indicate that there are hyperlinks. Does the styling need to be applied, explicitly or is there a defa...

Implemented in commit d804010. I now explicitly apply hyperlink font styling on linked Case Number cells (color: 0563C1 + underline: true) in addition to the hyperlink target, so spreadsheet clients can show a clear visual indicator similar to standard hyperlink styling. This is a backend export-only change (no in-app UI surface changed).

Copilot AI changed the title Make exported case numbers clickable hyperlinks in XLSX case export Make exported case numbers clickable and visibly styled hyperlinks in XLSX case export Feb 15, 2026
@jayhill
Copy link
Contributor

jayhill commented Feb 15, 2026

@copilot I deployed these changes , but the case number links still did not show link-like formatting.

Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot I deployed these changes , but the case number links still did not show link-like formatting.

Updated in commit ff31b0c. I switched linked case-number cells to use an Excel HYPERLINK(...) formula (and kept link target metadata), which should make spreadsheet clients render them with native hyperlink styling more reliably. I also added test coverage for formula escaping edge cases. No in-app UI changed (export-file behavior only).

Copilot AI changed the title Make exported case numbers clickable and visibly styled hyperlinks in XLSX case export Make exported case numbers clickable with reliably visible hyperlink formatting in XLSX case export Feb 15, 2026
@jayhill
Copy link
Contributor

jayhill commented Feb 15, 2026

@copilot I see the HYPERLINK formula, but the text is still not formatted.
image

Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot I see the HYPERLINK formula, but the text is still not formatted.
<img width="531" height="160" alt="image" src="https://github.com/user-attachments/assets/3b7f6260-e40a-46b2-89cd-5f4fb4cab6...

Updated in commit 6d481cc. I now keep the HYPERLINK(...) formula and also persist explicit hyperlink styling by writing with cellStyles: true and setting the linked Case Number font to blue + underlined. This should make the hyperlink formatting appear in exported files instead of only showing the formula. Screenshot for context:

Spreadsheet hyperlink display

@jayhill
Copy link
Contributor

jayhill commented Feb 15, 2026

@copilot
You are being asked to fix the problem where hyperlinks in an xlsx file generated with the SheetJS xlsx package don’t look clickable in Excel (no blue color / underline). The underlying cause is that:

Excel doesn’t automatically style hyperlinks unless they are actual cell hyperlink relationships.

The default open-source/community xlsx package does not reliably write cell styles (cell.s).

Styling (color/underline) in the community version has no effect unless using a styling-enabled fork or SheetJS Pro.

✔️ Task

Generate instructions and example code for:

Correctly adding real hyperlinks via the l property (Hyperlink Relationship) instead of using an HYPERLINK formula.

(If applicable) optionally mention a styling-capable package like xlsx-js-style if the user needs custom visual styling.

🧾 Instructions to Generate

Your reply must include:

  1. Explanation of the hyperlink behavior

State that SheetJS stores hyperlink targets in the cell object’s l key.

Note that Excel doesn’t automatically apply hyperlink formatting, and styling in the community xlsx package is not supported.

Example explanation:

In SheetJS, a hyperlink is defined on a cell via the l property:

ws["A1"].l = { Target: "https://example.com" };


Excel will recognize the hyperlink and make the cell clickable, but the default open-source writer does not reliably write visible styles (blue/underline).


---

### **2) Correct code pattern (preferred)**

Replace your current formula + styling approach with:

```js
const cellRef = XLSX.utils.encode_cell({ r: row, c: caseNumberColumn });
const cell = ws[cellRef];

if (cell && caseUrl) {
  cell.t = "s";                // text cell
  cell.v = caseNumber;         // display the case number
  delete cell.f;               // remove any formula
  cell.l = { Target: caseUrl }; // set hyperlink relationship
}

3) Optional: Use a style-capable package

If the user must visually style hyperlinks (e.g., blue + underline), include instructions to install and use a SheetJS fork with style support like xlsx-js-style:

npm install xlsx-js-style


Then generate a styled hyperlink cell:

cell.s = {
  font: { color: { rgb: "FF0563C1" }, underline: true }
};


Mention that this package does write styles to the file, unlike the community xlsx package.

4) Summary or troubleshooting tips

Add a short note like:

Don’t mix l and f for the same cell. Use one method (prefer l).

If styles still don’t appear, use the styling fork or SheetJS Pro.

🟡 Final Deliverable

Your output should be formatted like:

A short explanation of the issue

Correct code snippet(s)

Optional instructions for styling support

One or two brief bullet summary tips

That’s it  generate concise, clear, correctness-focused instructions for the user.

Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot
You are being asked to fix the problem where hyperlinks in an xlsx file generated with the SheetJS xlsx package don’t look clickable in Excel (no blue color / underline). The underlying c...

Implemented in commit 5d7356d.

The export now uses real SheetJS hyperlink relationships (cell.l) and removes formula/style mixing. In the community xlsx writer, hyperlinks are clickable via l, but blue/underline styling is not reliably written from cell.s.

const cellRef = XLSX.utils.encode_cell({ r: row, c: caseNumberColumn });
const cell = ws[cellRef];

if (cell && caseUrl) {
  cell.t = 's';
  cell.v = caseNumber;
  delete cell.f;
  cell.l = { Target: caseUrl };
}

If you need guaranteed visual styling in output files, use a styling-capable package (e.g. xlsx-js-style):

npm install xlsx-js-style
cell.s = {
  font: { color: { rgb: 'FF0563C1' }, underline: true }
};

Tips:

  • Prefer l for hyperlinks; don’t mix l and f on the same cell.
  • For visible hyperlink styling with OSS tooling, use xlsx-js-style (or SheetJS Pro).

Screenshot reference:
Spreadsheet hyperlink display

Copilot AI changed the title Make exported case numbers clickable with reliably visible hyperlink formatting in XLSX case export Make exported case numbers clickable hyperlinks via SheetJS relationship links in XLSX export Feb 15, 2026
@jayhill
Copy link
Contributor

jayhill commented Feb 16, 2026

@copilot Okay, well the community version of sheetjs does not support styling.
Switch the implementation to build using exceljs. Preserve all the existing behavior but reimplement with the new library.
Update or re-write tests accordingly.

Co-authored-by: jayhill <116148+jayhill@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 16, 2026

@copilot Okay, well the community version of sheetjs does not support styling.
Switch the implementation to build using exceljs. Preserve all the existing behavior but reimplement with the new libra...

Implemented in commit 39ba960.

Export generation is now reimplemented with exceljs (instead of SheetJS community writer), preserving existing row behavior and making case-number hyperlinks/styling native through ExcelJS cell values:

  • cell.value = { text: caseNumber, hyperlink: caseUrl }
  • cell.font = { color: { argb: 'FF0563C1' }, underline: true }

I also updated dependency/lock files and rewrote the export handler tests to mock and validate the ExcelJS workbook API behavior.

Screenshot reference:
Spreadsheet hyperlink display

Copilot AI changed the title Make exported case numbers clickable hyperlinks via SheetJS relationship links in XLSX export Make exported case numbers clickable and visibly styled hyperlinks using ExcelJS in XLSX export Feb 16, 2026
@jayhill jayhill closed this Feb 16, 2026
@jayhill jayhill deleted the copilot/update-export-feature-hyperlinks branch February 16, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants